package Unite;

import java.util.HashMap;
import java.util.Map;

public class AttributeMap {
	private Map<Integer, Integer> _attributesMap;
	private int _weight;

	public final static int AGILITY = 0, ATTRACTIVENESS = 1, CHARISMA = 2,
			CONCENTRATION = 3, CONSTITUTION = 4, DEXTERITY = 5, PRESENCE = 6,
			RATIONNALITY = 7, STRENGHT = 8, TACTIC = 9, TENACITY = 10,
			VIGILANCE = 11, WILL = 12, WISDOM = 13;

	/* On a scale from 0 to 10, 10 being superman, and 0 being a legless ant */
	/**
	 * @param agl
	 * @param att
	 * @param cha
	 * @param conc
	 * @param cons
	 * @param dex
	 * @param pre
	 * @param rat
	 * @param str
	 * @param tac
	 * @param ten
	 * @param vig
	 * @param will
	 * @param wis
	 */
	public AttributeMap(int agl, int att, int cha, int conc, int cons, int dex,
			int pre, int rat, int str, int tac, int ten, int vig, int will,
			int wis) {
		_attributesMap = new HashMap<Integer, Integer>();
		setAgility(agl);
		setAttractiveness(att);
		setCharisma(cha);
		setConcentration(conc);
		setConstitution(cons);
		setDexterity(dex);
		setPresence(pre);
		setRationnality(rat);
		setStrenght(str);
		setTactic(tac);
		setTenacity(ten);
		setVigilance(vig);
		setWill(will);
		setWisdom(wis);
		_weight = calculateWeight();
	}

	/**
	 * @return
	 */
	private int calculateWeight() {
		int weight = 0;
		for (int i : _attributesMap.values())
			weight += i;
		return weight / 13;
	}

	/**
	 * @param agl
	 */
	private void setAgility(int agl) {
		_attributesMap.put(AGILITY, agl);
	}

	/**
	 * @param att
	 */
	private void setAttractiveness(int att) {
		_attributesMap.put(ATTRACTIVENESS, att);
	}

	/**
	 * @param cha
	 */
	private void setCharisma(int cha) {
		_attributesMap.put(CHARISMA, cha);
	}

	/**
	 * @param conc
	 */
	private void setConcentration(int conc) {
		_attributesMap.put(CONCENTRATION, conc);
	}

	/**
	 * @param cons
	 */
	private void setConstitution(int cons) {
		_attributesMap.put(CONSTITUTION, cons);
	}

	/**
	 * @param dex
	 */
	private void setDexterity(int dex) {
		_attributesMap.put(DEXTERITY, dex);
	}

	/**
	 * @param pre
	 */
	private void setPresence(int pre) {
		_attributesMap.put(PRESENCE, pre);
	}

	/**
	 * @param rat
	 */
	private void setRationnality(int rat) {
		_attributesMap.put(RATIONNALITY, rat);
	}

	/**
	 * @param str
	 */
	private void setStrenght(int str) {
		_attributesMap.put(STRENGHT, str);
	}

	/**
	 * @param tac
	 */
	private void setTactic(int tac) {
		_attributesMap.put(TACTIC, tac);
	}

	/**
	 * @param ten
	 */
	private void setTenacity(int ten) {
		_attributesMap.put(TENACITY, ten);
	}

	/**
	 * @param vig
	 */
	private void setVigilance(int vig) {
		_attributesMap.put(VIGILANCE, vig);
	}

	/**
	 * @param will
	 */
	private void setWill(int will) {
		_attributesMap.put(WILL, will);
	}

	/**
	 * @param wis
	 */
	private void setWisdom(int wis) {
		_attributesMap.put(WISDOM, wis);
	}

	/**
	 * @return
	 */
	public int getWeight() {
		return _weight;
	}

	/**
	 * @param attr
	 * @return
	 */
	public int get(int attr) {
		return _attributesMap.get(attr);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	public boolean equals(Object o) {
		if (o instanceof AttributeMap) {
			int i = 0;
			for (int value : _attributesMap.values())
				if (value != ((AttributeMap) o).get(i++))
					return false;
		}
		return true;
	}
}
